﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wormhole.Engine.CardLibrary.BaseCardTypes
{
	/// <author>Rodney McKay</author>
	/// <date>04 April 2008</date>
	/// <summary>
	/// The base class for cards that have a cost.
	/// </summary>
	public abstract class CostCard : Card
	{
		#region Properties
		
		/// <summary>
		/// The card cost.
		/// </summary>
		public abstract int Cost { get; }
		
		#endregion

		#region Constructor
		/// <summary>
		/// Initialize a new instance of the class.
		/// </summary>
		/// <param name="owner">The card owner.</param>
		public CostCard(Player.Player owner) : base(owner)
		{

		}
		#endregion

		#region Play
		/// <summary>
		/// Play the card from the hand.
		/// </summary>
		public override void Play()
		{
			if (this.CanPlay())
			{
				this.Owner.Power -= this.Cost;
				base.Play();
			}
		}
		#endregion

		#region Can Play
		/// <summary>
		/// Can the card be played from the players hand?
		/// </summary>
		/// <returns>Returns true if the card can be played.</returns>
		public override bool CanPlay()
		{
			bool canPlay = false;
			if (this.Owner.Power >= this.Cost)
				if (this.Owner.HasPriority)
				{
					if ((!this.IsVillainCard) && (this.Game.GameTurn.HeroPlayer == this.Owner))
						canPlay = true;
					else if ((this.IsVillainCard) && (this.Game.GameTurn.VillianPlayer == this.Owner))
							canPlay = true;
				}

			return canPlay;
		}
		#endregion
	}
}
